<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>股票管理</title>
<%@include file="../static/include/head.jsp"%>

<script src="<%=request.getContextPath()%>/static/assets/global/scripts/metronic.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/static/assets/admin/layout/scripts/layout.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/static/assets/admin/layout/scripts/quick-sidebar.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/static/assets/admin/layout/scripts/demo.js" type="text/javascript"></script>

<link href="<%=request.getContextPath()%>/static/assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<script src="<%=request.getContextPath()%>/static/assets/global/plugins/datatables/media/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/static/assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js" type="text/javascript"></script>

<link href="<%=request.getContextPath()%>/static/assets/global/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" type="text/css" />
<script src="<%=request.getContextPath()%>/static/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script>

<script>
	jQuery(document).ready(function() {
		Metronic.init();
		Layout.init();
		QuickSidebar.init();
		Demo.init();
		$("#serchButton").click(function() {
			tableStockInit.fnDraw();
		});
		
		$('.date-picker').datepicker({
			language : 'cn',
			todayBtn : false,
			autoclose : true,
			forceParse : true,
			format : "yyyy-mm-dd"
		});
			
		var tableStockInit = $("#table_stock").dataTable({
				"paging" : true, //翻页功能
				"lengthChange" : true, //改变每页显示数据数量
				"searching" : false, //过滤功能
				"ordering" : true, //排序功能
				"order" : [ [ 0, "desc" ] ],
				"processing" : false,
				"serverSide" : true, //服务器数据
				"lengthMenu" : [ 10, 15, 30, 50 ],
				"pageLength" : 10,
				"language" : {
				"processing" : "努力加载中...",
				"search" : "搜索&nbsp;:",
				"lengthMenu" : "一页显示 _MENU_ 条数据",
				"info" : "当前第 _START_ 条到第 _END_ 条记录，共 _TOTAL_ 条记录",
				"loadingRecords" : "正在努力的加载数据...",
				"infoEmpty" : "当前第 0 条到第 0 条记录，共 0 条记录",
				"emptyTable" : "没有找到您查询的数据信息"
			},
			"ajax" : {
				"url" : "getStockOperationRecordPage",
				"type" : "POST",
				"data" : function(data) {
					data.stockName = $("#stockName").val();
					data.stockCode = $("#stockCode").val();
				}
			},
			"columns" : [{
					"data" : "id"
				},{
					"data" : "stockName"
				},{
					"data" : "name"
				},{
					"data" : "description"
				},{
					"width": "120px",
					"data" : "createTime",
					render: function ( data, type, row ) {
						if(data!=null){
							return new Date(data).toLocaleString().replace("/","年").replace("/","月").replace(" ","日 ").split(" ")[0];
				        }else{
				        	return '';
				        }
				    }
				}]
		});
	});
	
 	// 查看按钮初始化
	function lookStockInit(item) {
		clearInput();
		$("#edit_stock_btn").show();
	    $("#submit_stock_btn").hide();
	    $("#stockInfoTable input[type='text']").each(function(e){
	    	$(this).attr("readonly","readonly");
	    	$(this).attr("style","border:0px");
	    	$(this).css("background-color",$(this).parents('td').css('background-color'));
		 });
	    $("#stockInfoTable textarea").each(function(e){
	    	$(this).attr("readonly","readonly");
	    	$(this).attr("style","border:0px");
	    	$(this).css("background-color",$(this).parents('td').css('background-color'));
		 });
		$("#managerStock_title").text("查看股票详情");
		$("#managerStock_color").attr("class","portlet box blue");
        var tableRow = item.parents('tr')[0];
        var idTh = $(tableRow).children().get(0);
        $.post("<%=request.getContextPath()%>/getStockById", 
    		{ 
    			id: $(idTh).text()
    		}, 
    		function(json){
    			for(var index in json.data){
    				var val = json.data[index];
    				if(typeof($("#stock_"+index+"_edit")) != "undefined"){
    					$("#stock_"+index+"_edit").val(json.data[index]);
    					<!-- 下拉框处理 -->
						if(index=='ammeterBeiLv'){
							$("#stock_"+index+"_edit").val(json.data[index]);						
						}
    				}
    			}
    			
				$("#managerStock_div").modal("show");
			},"json"
    	);
    };
	
</script>
</head>
<body class="page-header-fixed page-quick-sidebar-over-content">
	<%@include file="../static/include/header.jsp"%>
	<div class="clearfix"></div>
	<div class="page-container">
		<%@include file="../static/include/sidebar.jsp"%>
		<!-- BEGIN CONTENT -->
		<div class="page-content-wrapper">
			<div class="page-content">
				<!-- BEGIN STYLE CUSTOMIZER -->
				<%@include file="../static/include/styles.jsp"%>
				<!-- END STYLE CUSTOMIZER -->
				<div class="row">
					<div class="col-md-12">
						<!-- BEGIN PAGE HEADER-->
						<h3 class="page-title">
							股票管理 <small>股票操作记录一览</small>
						</h3>
						<div class="page-bar">
							<ul class="page-breadcrumb">
								<li><i class="fa fa-home"></i> <a href="index">主页</a> <i class="fa fa-angle-right"></i></li>
								<li><a href="stockManager">股票管理</a></li>
							</ul>
						</div>
						<!-- END PAGE HEADER-->
						<!-- BEGIN ROW -->
						<div class="portlet box blue-madison">
							<div class="portlet-title">
								<div class="caption">
									<i class="fa fa-user"></i>股票操作记录
								</div>
								<div class="tools">
									<a href="javascript:;" class="collapse"></a>
								</div>
							</div>
							<div class="portlet-body">
								<div>
									<ul class="nav nav-tabs">
										<li style="float: right; margin-left: 5px">
											<button id="serchButton" type="button" class="btn green">搜索</button>
										</li>
										<li style="float: right; margin-left: 5px"><input id="stockCode" type="text" class="form-control" placeholder="请输入股票编码"></li>
										<li style="float: right"><input id="stockName" type="text" class="form-control" placeholder="请输入股票名称"></li>
									</ul>
									<div class="tab-pane fade active in" id="tab_1_1">
										<table id="table_stock" class="table table-striped table-hover table-bordered">
											<thead>
												<tr>
													<th>编号</th>
													<th>股票名称</th>
													<th>操作名称</th>
													<th>操作描述</th>
													<th>操作时间</th>
													<!-- <th>操作</th> -->
												</tr>
											</thead>
											<tbody>
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
						<!-- END ROW -->
					</div>
				</div>
			</div>
			<!-- END CONTENT -->
		</div>
	</div>
	<%@include file="../static/include/footer.jsp"%>
	<!-- modal BEGIN -->
	<div id="managerStock_div" class="modal fade" tabindex="-1" aria-hidden="true">
		<div class="modal-dialog">
			<div id="managerStock_color" class="portlet box blue" style="width: 900px">
				<div class="portlet-title">
					<div class="caption">
						<i class="fa fa-user"></i>电费管理
					</div>
					<div id="managerBill_title" class="tools"></div>
				</div>
				<div class="portlet-body form">
					<div class="form-body">
						<table style="margin: 3px" class="table table-striped table-hover table-bordered" id="stockInfoTable">
							<tr hidden="true">
								<td>编号</td>
								<td><input class="col-md-12" id="stock_id_edit" type="text" readonly="readonly"></input></td>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<td>名称</td>
								<td><input class="col-md-12" id="stock_name_edit" type="text"></input></td>
								<td>编码</td>
								<td><input class="col-md-12" id="stock_code_edit" name="stock_code_edit" type="text"></input></td>
							</tr>
							<tr>
								<td>收盘价</td>
								<td><input class="col-md-12" id="stock_value_edit" type="text"></input></td>
								<td>估值</td>
								<td><input class="col-md-12" id="stock_appraisement_edit" type="text"></input></td>
							</tr>
							<tr>
								<td>预期收益</td>
								<td><input id="stock_earnings_edit" name="stock_earnings_edit"  type="text"/></td>
								<td>状态</td>
								<td><input class="col-md-12" id="stock_status_edit" type="text"></input></td>
							</tr>												
							<tr>
								<td>备注</td>
								<!-- <td colspan="3"><input class="col-md-12" id="stock_remark_edit" type="text"></input></td> -->
								<td colspan="3" ><textarea rows="3" cols="20" class="col-md-12" id="stock_remark_edit"></textarea></td>
							</tr>
						</table>
					</div>
					<div class="form-actions right">
						<button type="button" data-dismiss="modal" class="btn default">返回</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- modal END -->	
</body>
</html>
